package com.pro01.apirednote.dto;

import com.pro01.apirednote.pojo.Content;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Data
public class ContentWithFilesResponse {
    private Long id;
    private String title;
    private String type; // IMAGE / VIDEO / DOC
    private String description;
    private Integer likeCount;
    private Integer commentCount;
    private Integer viewCount;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    private List<String> fileUrls; // 附带的文件路径
    
    /**
     * 从Content对象和fileUrls列表创建ContentWithFilesResponse
     * @param content 内容对象
     * @param fileUrls 文件URL列表
     * @return ContentWithFilesResponse实例
     */
    public static ContentWithFilesResponse fromContent(Content content, List<String> fileUrls) {
        ContentWithFilesResponse response = new ContentWithFilesResponse();
        response.setId(content.getId());
        response.setTitle(content.getTitle());
        response.setType(content.getType());
        response.setDescription(content.getDescription());
        response.setLikeCount(content.getLikeCount());
        response.setCommentCount(content.getCommentCount());
        response.setViewCount(content.getViewCount());
        response.setCreatedAt(content.getCreatedAt());
        response.setUpdatedAt(content.getUpdatedAt());
        response.setFileUrls(fileUrls);
        return response;
    }
}